import 'dart:io';

import 'package:flutter/material.dart';
import 'package:test1/FirstPage.dart';
import 'package:test1/SecondPage.dart';

class BottomNavigationPage extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: Scaffold(
        body: MyBottomPage(),
      ),
    );
  }



}

class MyBottomPage extends StatefulWidget {
  @override
  _MyBottomState createState() => _MyBottomState();
}

class _MyBottomState  extends State<MyBottomPage> {
  int _selectIndex = 0;
  final _widgetOptions = [
    Text('信息1'),
    Text('信息2'),
    Text('信息3'),
    Text('信息4'),

  ];
  @override
  Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       appBar: AppBar(
         title: Text('底部导航栏'),
       ),
       body: Center(
         child: _widgetOptions.elementAt(_selectIndex),
       ),
       bottomNavigationBar: BottomNavigationBar(
         items: <BottomNavigationBarItem>[
           BottomNavigationBarItem(icon: Icon(Icons.chat),title: Text('信息1')),
           BottomNavigationBarItem(icon: Icon(Icons.phone),title: Text('信息2')),
           BottomNavigationBarItem(icon: Icon(Icons.hotel),title: Text('信息3')),
         ],
         currentIndex: _selectIndex,
         fixedColor: Colors.deepPurple,
         onTap: _onItemTaped,
       ),
     ),
   );
  }

  void _onItemTaped(int index) {
    setState(() {
      _selectIndex = index;
    });
  }
}


